package twel.probenprophet.base.utility;

public class IntTriple {

	private final int[] array = new int[3];

	public IntTriple(int first, int second, int third) {
		array[0] = first;
		array[1] = second;
		array[2] = third;
	}

	public int getFirst() {
		return array[0];
	}

	public int getSecond() {
		return array[1];
	}

	public int getThird() {
		return array[2];
	}

	public int get(int index) {
		try {
			return array[index];
		} catch (ArrayIndexOutOfBoundsException e) {
			throw new IllegalArgumentException("legal argument values are 0, 1 and 2", e);
		}
	}

	public boolean hasThreeValuesOf(int value) {
		return getFirst() == value && getSecond() == value && getThird() == value;
	}

	public boolean hasTwoValuesOf(int value) {
		boolean firstAndSecond = getFirst() == value && getSecond() == value;
		boolean firstAndThird = getFirst() == value && getThird() == value;
		boolean secondAndThird = getSecond() == value && getThird() == value;

		return firstAndSecond || firstAndThird || secondAndThird;
	}

	public void increaseAllBy(int addend) {
		for (int i = 0; i < array.length; i++) {
			array[i] = array[i] + addend;
		}
	}
}
